home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Leonardo the Inventor
/
Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso
/
LEOWINMV
/
QUIZGAM.DIR
/
00180_Script_GET - PUT - SET HANDLERS
< prev
next >
Wrap
Text File
|
1996-03-19
|
7KB
|
221 lines
-- -----------------------------------------------------------------------------
-- handler getQuestionForTile retrieves a questionnumber from field "questionnumbers"
-- and displays the corresponding question
on getQuestionForTile aTile,qSprite,aSprite
global questionIndex,questionNumbers,QCastName,ACastName
-- retrieve the number of the next question to ask
set index = getItemFromLineFromVar(questionIndex,aTile,questionNumbers)
set nextQuestion = getItemFromLineFromVar(index,aTile,questionNumbers)
-- display the question AND it's answer on stage
displayPartOfQuestionOfTile QCastName,nextQuestion,qSprite
displayPartOfQuestionOfTile ACastName,nextQuestion,aSprite
end
-- -----------------------------------------------------------------------------
-- handler getAnswerClicked returns the number of the answerButton the user
-- clicked. Top button = 1.
on getAnswerClicked aClickV,aSprite,nrOfAnswers
global buttonHeight
set castOffset = the locV of sprite aSprite
-- determine clickLoc relative to castMember
set clickV = (aClickV - castOffset)
-- Determine top, middle and bottom
set topOfAnswerSprite = 0
set bottomOfAnswerSprite = the height of cast (the castNum of sprite aSprite)
set middleOfAnswerSprite = bottomOfAnswerSprite / 2
-- 3 ANSWERS: test if the clickloc was on top, middle or bottom of cast.
if (clickV >= 0) AND (clickV <= buttonHeight) then
set answer = 1
else
if (clickV >= (middleOfAnswerSprite - (buttonHeight / 2))) AND ¼
(clickV <= (middleOfAnswerSprite + (buttonHeight / 2))) then
set answer = 2
else
-- if there are 3 answers, user clicked 3; if there are 2 answers, user clicked 2
set answer = nrOfAnswers
end if
end if
return answer
end
-- -----------------------------------------------------------------------------
-- handler getStartNr returns the number of the first question for a game
on getStartNr
global nrOfQuestionsPerTile,nrOfTiles,gameNr
if gameNr = 1 then
return 1
else
return nrOfQuestionsPerTile * nrOfTiles * (gameNr - 1) + 1
end if
end
-- -----------------------------------------------------------------------------
-- handler getGameNr returns the number of the game we're currently in
on getGameNr
global gameNr
return gameNr
end
-- -----------------------------------------------------------------------------
-- handler getEndNr returns the number of the last question for a game
on getEndNr
global nrOfQuestionsPerTile,nrOfTiles,gameNr
return nrOfQuestionsPerTile * nrOfTiles * gameNr
end
-- -----------------------------------------------------------------------------
-- handler getSourceList returns an ordered list of maxEntries items
on getSourceList startNr,endNr
set sortedlist = []
repeat with i = startNr to endNr
add sortedlist,i
end repeat
return sortedlist
end
-- -----------------------------------------------------------------------------
-- handler getCurrentQuestion returns the question currently shown in tile aTile
on getCurrentQuestion aTile
global questionNumbers,questionIndex
set currQuestion = getItemFromLineFromVar (questionIndex,aTile,questionNumbers)
return getItemFromLineFromVar (currQuestion,aTile,questionNumbers)
end
-- -----------------------------------------------------------------------------
-- handler getCorrectAnswer returns the correct answer for a question
on getCorrectAnswer aQuestion
global correctAnswer,answers
return getItemFromLineFromVar (1,aQuestion,answers)
end
-- -----------------------------------------------------------------------------
-- handler getItemFromLineFromVar returns item anItem from line aLine from variable aVar
on getItemFromLineFromVar anItem,aLine,aVar
return item value(anItem) of line aLine of aVar
end
-- -----------------------------------------------------------------------------
-- handler putListIntoLineOfField puts the text of a question into a text field of a tile
on putListIntoLineOfField aList,aLine,aField
set lastItem = count(alist)
repeat with currItem = 1 to lastItem
put getAt(aList,curritem) & the itemDelimiter after line aLine of field aField
end repeat
put RETURN after line aLine of field aField
end
-- -----------------------------------------------------------------------------
-- handler setSpriteVisibility sets the visible of sprite aSprite to FALSE
on setSpriteVisibility aSprite,state
set the visible of sprite aSprite to state
updateStage
end
-- -----------------------------------------------------------------------------
-- handler setItemOfLineOfVartoValue changes the value and returns the updated variable
on setItemOfLineOfVartoValue anItem,aLine,aVar,aValue
put aValue into item anItem of line aLine of aVar
return aVar
end
-- -----------------------------------------------------------------------------
-- handler setPuppets sets puppetsprites
on setPuppets startSprite,endSprite,state
repeat with currSprite = startSprite to endSprite
puppetSprite currSprite, state
end repeat
end
-- -----------------------------------------------------------------------------
-- handler setStretch sets the stretch of sprites firstSprite to lastSprite to state
on setStretch firstSprite,lastSprite,state
repeat with currSprite = firstSprite to lastSprite
set the stretch of sprite currSprite = state
end repeat
end
-- -----------------------------------------------------------------------------
-- handler getPathDelimiter returns a "\" if movie running on a PC, a "" otherwise.
on getPathDelimiter
if the machineType = 256 then
set delimiter = "\"
else
set delimiter = ":"
end if
return delimiter
end
-- -----------------------------------------------------------------------------
-- handler setSpritesVisibility sets visible of sprites containing q & answer = TRUE
on setSpritesVisibility firstSprite,lastSprite,state
repeat with currSprite = firstSprite to lastSprite
setSpriteVisibility currSprite,state
end repeat
end
-- -----------------------------------------------------------------------------
-- handler getSpritePosition returns the position of sprite aSprite
on getSpritePosition aSprite
set aSpriteLocH = the locH of sprite aSprite
set aSpriteLocV = the locV of sprite aSprite
return [aSpriteLocH,aSpriteLocV]
end
-- -----------------------------------------------------------------------------
-- handler setSpriteToPosition sets sprite aSprite to location aLoc
on setSpriteToPosition aSprite,aLoc
set the locH of sprite aSprite to getAt(aLoc,1)
set the locV of sprite aSprite to getAt(aLoc,2)
updateStage
end